package com.gitee.wsl.compose.ext


import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.gitee.wsl.common.ui.base.HasPadding

/**
 * Sets a padding value for each edge of the rectangle individually.
 */
@Composable
fun <P : HasPadding> P.setPadding(
    start: Dp = 0.dp,
    top: Dp = 0.dp,
    end: Dp = 0.dp,
    bottom: Dp = 0.dp,
): P =
    apply {
        padding.setPadding(
            start.value,
            top.value,
            end.value,
            bottom.value,
        )
    }

/**
 * Sets the horizontal and vertical padding for the rectangle.
 */
@Composable
fun <P : HasPadding> P.setPadding(
    horizontal: Dp = 0.dp,
    vertical: Dp = 0.dp,
): P =
    apply {
        padding.setPadding(
             horizontal.value,
             vertical.value,
             horizontal.value,
             vertical.value,
        )
    }

/**
 * Sets a common padding value for each edge of the rectangle.
 */
@Composable
 fun <P : HasPadding> P.setPadding(all: Dp = 0.dp): P =
    apply {
        padding.setPadding(
            all.value,
            all.value,
            all.value,
            all.value,
        )
    }
